from web.scraper.translate.line1.main import BaiduTranslateSpider
from django.http import JsonResponse

spider = BaiduTranslateSpider()

# 翻译
def translate(request):
    text = request.GET.get('text')
    from_lang = request.GET.get('from_lang')
    to_lang = request.GET.get('to_lang')
    result = spider.translate(text, from_lang, to_lang)
    return JsonResponse(result, safe=False)

# 获取翻译建议
def sug(request):
    text = request.GET.get('text')
    result = spider.sug(text)
    return JsonResponse(result, safe=False) 

# 识别语言
def identify_language(request):
    text = request.GET.get('text')
    result = spider.identify_language(text)
    return JsonResponse(result, safe=False)




